package com.example.day1031_dataeven.slice;

import com.example.day1031_dataeven.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.TextField;
import ohos.agp.window.dialog.ToastDialog;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import java.awt.*;
import java.util.List;

public class MainAbilitySlice extends AbilitySlice {

    private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, "My_AG");

    private TextField mName;                //姓名
    private TextField mNumber;              //学号
    private TextField mAge;             //年龄
    private TextField mGender;             //性别
    private TextField mGrade;             //成绩


    private Button mSave;             //保存信息按钮
    private Button mSearch;             //搜索按钮



    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        inits();

    }

    private void inits() {

        mName = (TextField) findComponentById(ResourceTable.Id_main_tfname);
        mNumber = (TextField) findComponentById(ResourceTable.Id_main_tfstunumber);
        mAge = (TextField) findComponentById(ResourceTable.Id_main_tfage);
        mGender = (TextField) findComponentById(ResourceTable.Id_main_tfgender);
        mGrade = (TextField) findComponentById(ResourceTable.Id_main_tfgrade);

        mSave = (Button) findComponentById(ResourceTable.Id_main_tfsave);
        mSearch = (Button) findComponentById(ResourceTable.Id_main_tfsearch);


        mSearch.setClickedListener(component ->onclick());


    }

    private void onclick() {
        new ToastDialog(getContext()).setText("进入搜索页面").show();
        HiLog.info(LABEL_LOG, "onclick");
        present(new SearchDataSlice(),new Intent());
    }



    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
